package org.example.jwt1.utils;

import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.springframework.security.core.Authentication;

import java.util.Date;

public class JwtUtils {
    public static String generateToken(Authentication authentication){
        String token = Jwts.builder()
                .claim("authentication",authentication)
                .setSubject(authentication.getName())
                .setExpiration(new Date(System.currentTimeMillis()+3600000))
                .signWith(SignatureAlgorithm.HS256,"sike")
                .compact();
        return token;
    }
}
